-- 2D 的直线运动
local jass = require 'jass.common'
local japi = require 'jass.japi'
local msg  = require 'jass.message'

local mover = { }
setmetatable(mover,mover)
ac.mover.class['round'] = mover

mover['π'] = math.pi 

local mt = { }
mover.__index = mt 
extends(ac.mover)(mt)

-- 运动类型
mt.mover_type = 'round'

-- 持续时间
mt.time = -1

-- 周期
mt.pulse = 1.0

-- 初始角度
mt.angle = 0

-- local effect = mvr.effects[i]
-- local p = point - {angle + (i-1) * 360 / mvr.count, 512}
-- effect:set_point( p )
-- effect:set_facing( (angle + 90 + (360/mvr.count * (i-1)) )  % 360 )
-- effect:set_height( height)

-- 运动
function mt:move()
    local point = self.mover:get_point() 
    local angle = self.current_angle
    local height = point:get_height() + self.mover:get_height() + self.mover:get_impactZ()
    if self:notify ('on_move', point, angle, height) == false then 
        self:finish()
    end 
    angle = angle + self.current_speed
    if angle >= 360 then 
        angle = angle % 360
        self:notify ('on_round')
    end 
    self.current_angle = angle
end 

-- 初始化
function mt:init()
    ac.mover.__index.init(self)
    self.current_angle = self.angle
    self.current_speed = 360 * self.frame / self.pulse
end 

return mover